def max_score(reward1, reward2, k):
    n = len(reward1)
    # 计算每块奶酪给第一只老鼠和第二只老鼠的得分差
    diff = [(reward1[i] - reward2[i], i) for i in range(n)]
    # 按差值从大到小排序
    diff.sort(reverse=True)
    total = 0
    # 前k块分给第一只老鼠
    for i in range(n):
        idx = diff[i][1]
        if i < k:
            total += reward1[idx]
        else:
            total += reward2[idx]
    return total

if __name__ == "__main__":
    # 示例
    reward1 = [10, 20, 30, 40, 50]
    reward2 = [5, 25, 25, 35, 45]
    k = 2
    print(max_score(reward1, reward2, k))